package com.example.designpattern.lazyloading;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class LazyLoadingApp {

  public static void main(String[] args) {
    // 简单懒加载，线程不安全
    HolderSimple holderSimple = new HolderSimple();
    Gift gift = holderSimple.getHeavy();

    // 线程安全, 但是每次访问都有同步锁
    HolderThreadSafe holderThreadSafe = new HolderThreadSafe();
    gift = holderThreadSafe.getHeavy();

    // 利用jdk8新特性实现懒加载，性能最高
    Java8Holder java8Holder = new Java8Holder();
    gift = java8Holder.getHeavy();
    gift = java8Holder.getHeavy();

  }

}
